<?php       
		 $username=($_POST['username']);
		 $mail=($_POST['email']);
		 $phone=($_POST['phone']);
		 $permission=($_POST['permission']);
		  $section=$_POST['selections'];
		 
		  $listpsermit='';
		  if($permission!=1)
		foreach ($section as $t)
		{

			$listpsermit.= $t.",";
		}
		if(strlen($listpsermit)>0)
		{
		$listpsermit= substr($listpsermit,0,strlen($listpsermit)-1);
		}
$sql=sprintf("insert into tbluser (username,email,phone,section_ids,permission,password) values('%s','%s','%s','%s','%s',md5('sdds'))", $username,$mail,$phone,$listpsermit,$permission);																														
			$kq=mysql_query($sql)or die(mysql_error());
	 
	
	
			if(!$kq)
			{ 
				?>
				<script language="javascript">
				alert("Không thêm được người dùng!");
			
				</script>
				<?php
					header("Location:usere?id=".$id);
			}
			else
			{
				
			   
			header("Location:userlist");
				
			}

		

?>
